package com.zmhc.product.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zmhc.common.log.annotation.Log;
import com.zmhc.common.log.enums.BusinessType;
import com.zmhc.common.security.annotation.RequiresPermissions;
import com.zmhc.product.domain.StoreGoodsLabel;
import com.zmhc.product.service.IStoreGoodsLabelService;
import com.zmhc.common.core.web.controller.BaseController;
import com.zmhc.common.core.web.domain.AjaxResult;
import com.zmhc.common.core.utils.poi.ExcelUtil;
import com.zmhc.common.core.web.page.TableDataInfo;

/**
 * 店铺商品分类Controller
 *
 * @author ruoyi
 * @date 2023-12-11
 */
@RestController
@RequestMapping("/goodsLabel")
public class StoreGoodsLabelController extends BaseController {
    @Autowired
    private IStoreGoodsLabelService storeGoodsLabelService;

    /**
     * 查询店铺商品分类列表
     */
    @RequiresPermissions("product:goodsLabel:list")
    @GetMapping("/list")
    public TableDataInfo list(StoreGoodsLabel storeGoodsLabel) {
        startPage();
        List<StoreGoodsLabel> list = storeGoodsLabelService.selectStoreGoodsLabelList(storeGoodsLabel);
        return getDataTable(list);
    }

    /**
     * 导出店铺商品分类列表
     */
    @RequiresPermissions("product:goodsLabel:export")
    @Log(title = "店铺商品分类" , businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StoreGoodsLabel storeGoodsLabel) {
        List<StoreGoodsLabel> list = storeGoodsLabelService.selectStoreGoodsLabelList(storeGoodsLabel);
        ExcelUtil<StoreGoodsLabel> util = new ExcelUtil<StoreGoodsLabel>(StoreGoodsLabel.class);
        util.exportExcel(response, list, "店铺商品分类数据");
    }

    /**
     * 获取店铺商品分类详细信息
     */
    @RequiresPermissions("product:goodsLabel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(storeGoodsLabelService.selectStoreGoodsLabelById(id));
    }

    /**
     * 新增店铺商品分类
     */
    @RequiresPermissions("product:goodsLabel:add")
    @Log(title = "店铺商品分类" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StoreGoodsLabel storeGoodsLabel) {
        return toAjax(storeGoodsLabelService.insertStoreGoodsLabel(storeGoodsLabel));
    }

    /**
     * 修改店铺商品分类
     */
    @RequiresPermissions("product:goodsLabel:edit")
    @Log(title = "店铺商品分类" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StoreGoodsLabel storeGoodsLabel) {
        return toAjax(storeGoodsLabelService.updateStoreGoodsLabel(storeGoodsLabel));
    }

    /**
     * 删除店铺商品分类
     */
    @RequiresPermissions("product:goodsLabel:remove")
    @Log(title = "店铺商品分类" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(storeGoodsLabelService.deleteStoreGoodsLabelByIds(ids));
    }
}
